package service

import (
	"admin/app/model"
	"admin/tools"
)

var CurUser model.User

/*
* @desc 获取用户信息
* @param username 用户名
 */
func GetUserByName(username string, password string) *model.User {

	var user model.User
	result := tools.DB.Where("name = ?", username).Limit(1).Find(&user)
	if result.RowsAffected == 0 {
		return nil
	}
	return &user
}

func getUser(user model.User) {
	CurUser = user
}

func SetUser(user model.User) func() model.User {
	var curUser model.User
	curUser = user
	return func() model.User {
		return curUser
	}
}
